<template>
	<view class="box">
		<uni-popup ref="message" type="message">
			<uni-popup-message :type="msgType" :message="messageText" :duration="2000"></uni-popup-message>
		</uni-popup>
		<uni-card title="" extra="">
			<template v-slot:title>
				<view style="border-bottom: 1px solid #E6E6E6;">
					<view style="padding: 10px;">
						<text style="color: #1976D3; font-weight: bold;">功率设置</text>
					</view>
				</view>
			</template>
			<view class="uni-body" style="color: #000000!important; font-size: 18px!important; margin-bottom: 10px;">
				总功率限制值：{{ form.powerLimit || 0 }}瓦</view>
			<view class="uni-body" style="color: #000000!important; font-size: 18px!important; margin-bottom: 10px;">
				过功率阈值：{{ form.overPowerThreshold || 0 }}瓦</view>
			<view class="uni-body">说明：最大功率为电柜支持最大功率，负载超过此功率，电柜会停充，并发送告警信息</view>
			<view style="padding: 10px 0px 0px 0px; margin-top: 10px;">
				<button @click="editPower" class="mini-btn" type="primary" size="mini"
					style="background-color: #4DA7FF; float: right; width: 150rpx;">修改</button>
				<view class="clear"></view>
			</view>
		</uni-card>

		<uni-card title="" extra="" v-if="chargeCabintList.length>0">
			<template v-slot:title>
				<view style="border-bottom: 1px solid #E6E6E6;">
					<view style="padding: 10px;">
						<text style="color: #1976D3; font-weight: bold;">基础配置</text>
					</view>
				</view>
			</template>
			<view class="uni-body" style="color: #000000!important; font-size: 18px!important; margin-bottom: 10px;">
				<view class="uni-list-cell-db" v-for="(item,index) in chargeCabintList" :key="index">
					<view class="uni-input">仓{{item.chargingCabinetBinIndex}}：
					<text v-if="item.value&&item.value!='null'">{{lockFilter[item.value]}}</text>
					<text v-else style="color: #999999;"></text>
					</view>
				</view>
				<view style="padding: 10px 0px 0px 0px; margin-top: 10px;">
					<button @click="editCabintPower" class="mini-btn" type="primary" size="mini"
						style="background-color: #4DA7FF; float: right; width: 150rpx;">修改</button>
					<view class="clear"></view>
				</view>
			</view>
		</uni-card>
	</view>
</template>

<script>
	import {
		listParameterSending,
		equip
	} from "@/api/equip.js";
	import {
		overPowerCode,
		normallyOpenCode,
		totalPowerCode,
	} from '@/common/interface.js';
	export default {
		data() {
			return {
				form: {
					powerLimit: '',
					overPowerThreshold: '',
					lockStatus: '',
				},
				optionBox: {},
				msgType: '',
				messageText: '',
				editDisabled: true,
				code: '', //充电柜code
				equipid: '', //充电柜id
				lockData: [ //锁常开常闭
					{
						value: 'null',
						name: "请选择"
					},
					{
						value: "1",
						name: "高电平",
					},
					{
						value: "0",
						name: "低电平",
					},
				],
				chargeCabintList: [],
				lockFilter: {
					'1': '高电平',
					'0': '低电平'
				},
			}
		},
		onLoad(option) {
			this.code = option.code;
			this.equipid = option.equipid;
			this.getDetail(option);
			this.optionBox = option;
		},

		methods: {
			tempChange(e, index) {
				this.chargeCabintList[index].value = this.lockData[e.detail.value].value;
			},
			getDetail(option) {
				this.$Toast.loading('加载中');
				equip('/selectParams', 'get', {
						code: this.code,
						overPowerCode: overPowerCode,
						totalPowerCode: totalPowerCode,
						normallyOpenCode: normallyOpenCode
					}).then(res => {})
					.catch(err => {
						uni.hideLoading();
						err.forEach((item) => {
							if ('06040101' == item.protocolSemaphoreCode) {
								this.form.powerLimit = item.value;
							}
							if ('06042301' == item.protocolSemaphoreCode) {
								this.form.overPowerThreshold = item.value;
							}
						});
						this.chargeCabintList = err.filter(
							(item) => item.protocolSemaphoreCode == '06043401'
						);
					})
			},
			// 跳转修改功率
			editPower() {
				uni.navigateTo({
					url: '/pages/equipment/powerConfig?equipid=' + this.equipid + '&code=' + this.code
				});
			},
			editCabintPower(){
				uni.navigateTo({
					url:'/pages/equipment/cabintPower?equipid=' + this.equipid + '&code=' + this.code
				})
			},
		}
	}
</script>

<style>
	.listBtn {
		width: 154rpx;
		height: 50rpx;
		line-height: 50rpx;
		float: left;
		text-align: center;
		color: #FFFFFF;
		background-color: #4DA7FF;
		border-radius: 5px;
	}

	.maskVueHiddenShowWrapperGif {
		width: 400rpx;
		height: 300rpx;
		// background-color: red;
	}

	/deep/ button::after {
		border: none;
	}
	.uni-input{
		font-size: 32rpx;
	}
</style>
